package com.example.leetdemo.finash;

import java.util.HashSet;
import java.util.Set;

public class Solution6136 {

    public int arithmeticTriplets(int[] nums, int diff) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            set.add(nums[i]);
        }
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i] + diff) && set.contains(nums[i] + diff * 2)) {
                count++;
            }
        }
        return count;
    }

}
